$macro!(login)
$macro!(new)
$macro!(package)
+ $macro!(pkgid)
$macro!(read_manifest)
$macro!(run)
$macro!(test)
--- /dev/null
+use docopt;
+
+use cargo::ops;
+use cargo::core::MultiShell;
+use cargo::util::{CliResult, CliError};
+use cargo::util::important_paths::{find_root_manifest_for_cwd};
+
+docopt!(Options, "
+Print a fully qualified package specification
+
+Usage:
+ cargo pkgid [options] [<spec>]
+
+Options:
+ -h, --help Print this message
+ --manifest-path PATH Path to the manifest to the package to clean
+ -v, --verbose Use verbose output
+
+Given a <pkgid> argument, print out the fully qualified package id specifier.
+This command will generate an error if <pkgid> is ambiguous as to which package
+it refers to in the dependency graph. If no <pkgid> is given, then the pkgid for
+the local package is printed.
+
+This command requires that a lockfile is available and dependencies have been
+fetched.
+
+Example Package IDs
+
+ pkgid | name | version | url
+ |-----------------------------|--------|-----------|---------------------|
+ foo | foo | * | *
+ foo:1.2.3 | foo | 1.2.3 | *
+ crates.io/foo | foo | * | *://crates.io/foo
+ crates.io/foo#1.2.3 | foo | 1.2.3 | *://crates.io/foo
+ crates.io/bar#foo:1.2.3 | foo | 1.2.3 | *://crates.io/bar
+ http://crates.io/foo#1.2.3 | foo | 1.2.3 | http://crates.io/foo
+
+", flag_manifest_path: Option<String>, arg_spec: Option<String>)
+
+pub fn execute(options: Options,
+ shell: &mut MultiShell) -> CliResult<Option<()>> {
+ shell.set_verbose(options.flag_verbose);
+ let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path.clone()));
+
+ let spec = options.arg_spec.as_ref().map(|s| s.as_slice());
+ let spec = try!(ops::pkgid(&root, spec, shell).map_err(|err| {
+ CliError::from_boxed(err, 101)
+ }));
+ println!("{}", spec);
+ Ok(None)
+}
+
Update dependencies as recorded in the local lock file.
Usage:
- cargo update [options] [<name>]
+ cargo update [options] [<spec>]
Options:
-h, --help Print this message
This command requires that a `Cargo.lock` already exists as generated by
`cargo build` or related commands.
-If <name> is specified, then a conservative update of the lockfile will be
-performed. This means that only the dependency <name> will be updated. Its
-transitive dependencies will be updated only if <name> cannot be updated without
-updating dependencies. All other dependencies will remain locked at their
-currently recorded versions.
+If <spec> is given, then a conservative update of the lockfile will be
+performed. This means that only the dependency specified by <spec> will be
+updated. Its transitive dependencies will be updated only if <spec> cannot be
+updated without updating dependencies. All other dependencies will remain
+locked at their currently recorded versions.
-If <name> is not specified, then all dependencies will be re-resolved and
+If <spec> is not given, then all dependencies will be re-resolved and
updated.
-", flag_manifest_path: Option<String>, arg_name: Option<String>)
+
+For more information about package ids, see `cargo help pkgid`.
+", flag_manifest_path: Option<String>, arg_spec: Option<String>)
pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-update; args={}", os::args());
shell.set_verbose(options.flag_verbose);
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- ops::update_lockfile(&root, shell, options.arg_name, options.flag_aggressive)
+ ops::update_lockfile(&root, shell, options.arg_spec, options.flag_aggressive)
.map(|_| None).map_err(|err| CliError::from_boxed(err, 101))
}
-#![warn(warnings)]
use std::collections::HashSet;
use std::io::File;
--- /dev/null
+use ops;
+use core::{MultiShell, Source, PackageIdSpec};
+use sources::{PathSource};
+use util::{CargoResult, human};
+
+pub fn pkgid(manifest_path: &Path,
+ spec: Option<&str>,
+ _shell: &mut MultiShell) -> CargoResult<PackageIdSpec> {
+ let mut source = try!(PathSource::for_path(&manifest_path.dir_path()));
+ try!(source.update());
+ let package = try!(source.get_root_package());
+
+ let lockfile = package.get_root().join("Cargo.lock");
+ let source_id = package.get_package_id().get_source_id();
+ let resolve = match try!(ops::load_lockfile(&lockfile, source_id)) {
+ Some(resolve) => resolve,
+ None => return Err(human("A Cargo.lock must exist for this command"))
+ };
+
+ let pkgid = match spec {
+ Some(spec) => try!(resolve.query(spec)),
+ None => package.get_package_id(),
+ };
+ Ok(PackageIdSpec::from_package_id(pkgid))
+}
pub use self::cargo_upload::{upload, upload_configuration, UploadConfig};
pub use self::cargo_upload::{upload_login, http_proxy, http_handle};
pub use self::cargo_fetch::{fetch, resolve_and_fetch};
+pub use self::cargo_pkgid::pkgid;
mod cargo_clean;
mod cargo_compile;
mod cargo_package;
mod cargo_upload;
mod cargo_fetch;
+mod cargo_pkgid;